import request from '@/utils/request.js'

const wt_processStatisticsQueryApi = {
  list: '/processStatisticsQuery/findList',
  monthProHandling: '/processStatisticsQuery/monthProHandling',
  monthTopTenApplicants: '/processStatisticsQuery/monthTopTenApplicants',
  dailyApplicationVolume: '/processStatisticsQuery/dailyApplicationVolume',
  queryTaskUsers: '/processStatisticsQuery/queryTaskUsers',
  applyQuery: '/processStatisticsQuery/applyQuery',
  exportApplyQueryOutpu: '/flow/exportApplyQueryOutpu'
}

/**
 * 导出申请查询列表
 */
 export function exportApplyQueryOutpu(countryMap, pageInfo) {
  let cppageinfo = JSON.parse(JSON.stringify(pageInfo))
  cppageinfo.pageSize = 2147483647
  cppageinfo.pageNumber = 1
  return request({
    url: wt_processStatisticsQueryApi.exportApplyQueryOutpu,
    method: 'post',
    data: {countryMap: countryMap, pageInfo: cppageinfo},
    responseType: 'blob'
  })
}

/**
 * 申请查询
 * @param pageInfo
 * @return
 */
 export function applyQuery(pageinfo) {
  return request({
    url: wt_processStatisticsQueryApi.applyQuery,
    method: 'post',
    data: pageinfo
  })
}

/**
 * 本月每日申请量
 * @return
 */
export function dailyApplicationVolume() {
  return request({
    url: wt_processStatisticsQueryApi.dailyApplicationVolume,
    method: 'post'
  })
}

/**
 * 当月申请前十名流程
 * @return
 */
export function monthTopTenApplicants() {
  return request({
    url: wt_processStatisticsQueryApi.monthTopTenApplicants,
    method: 'post'
  })
}

/**
 * 统计本月流程任务的完成情况
 * @return List<{state: 已终止 | 未完成 | 已完成， total: 计数}>
 */
export function monthProHandling() {
  return request({
    url: wt_processStatisticsQueryApi.monthProHandling,
    method: 'post'
  })
}

/**
 * 查询流程实例列表
 * @param {*} parameter
 */
export function findList(parameter) {
  return request({
    url: wt_processStatisticsQueryApi.list,
    method: 'post',
    data: parameter
  })
}

/**
 * 查询当前人员配置
 * @return 人员配置列表
 */
export function queryTaskUsersByKey(key, sectionid) {
  return request({
    url: wt_processStatisticsQueryApi.queryTaskUsers,
    method: 'get',
    params: {
      key,
      sectionid
    }
  })
}